#!/usr/bin/perl #-------------------------------------------------- # Program to load the search box # # Last updated : Sept. 09, 03 # # Usage: # 1. use the following codes acting as server side include: # # #-------------------------------------------------- use CGI qw/:standard/; use CGI::Cookie; use CGI::Carp 'fatalsToBrowser'; use DBI; require "./env.ph"; $configfilename = ($whichlanguage eq "Japanese")? "config_japan.ph": "config.ph"; require $configfilename; require "./db.ph"; require "./subs.ph"; print "Content-type: text/html\n\n"; my ($html) = ""; my ($filename) = "../searchmenu.html"; my ($bid) = $ENV{ "QUERY_STRING" }; my (%brandnames) = (); my (%typenames) = (); if (-e $filename) { $dbh = &OpenDBI; if ($dbh) { $sql = "select distinct brandname from $PRODUCTSTABLE ". "where (enabled='1')and(category='Contact Lens')and(brandname<>'')"; $sth = $dbh -> prepare(qq[$sql]); if ($sth -> execute) { while ($hashrow = $sth->fetchrow_hashref) { $brandname = $hashrow->{brandname}; @brandlist = split( /\,/, $brandname ); foreach $brand (@brandlist) { $brand =~ s/^\s+//ig; $brand =~ s/\s+$//ig; next if ($brand eq ""); $found = 0; foreach $key (keys %brandnames) { if (lc($key) eq lc($brand)) { $found = 1; last; } } $brandnames{ $brand } = 1 if ($found == 0); } } } $sth -> finish; $sql = "select distinct typelist from $PRODUCTSTABLE ". "where (enabled='1')and(category='Contact Lens')and(typelist<>'')"; $sth = $dbh -> prepare(qq[$sql]); if ($sth -> execute) { while ($hashrow = $sth->fetchrow_hashref) { $typename = $hashrow->{typelist}; @typelist = split( /\|/, $typename ); foreach $type (@typelist) { $type =~ s/^\s+//ig; $type =~ s/\s+$//ig; next if ($type eq ""); $found = 0; foreach $key (keys %typenames) { if (lc($key) eq lc($type)) { $found = 1; last; } } $typenames{ $type } = 1 if ($found == 0); } } } $sth -> finish; $dbh->disconnect; } open( HTML, $filename ); while () { if (//i) { foreach $brand (sort keys %brandnames) { $_ .= "